﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnlineStore.Bll;
using OnlineStore.Dal;

namespace OnlineStore.Gui
{
    public partial class Search : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            bizProduct _bizProduct = new bizProduct();
            string keyword = Request.QueryString.Get("keyword");
            string type = Request.QueryString.Get("category_id");
            string Introduce = Request.QueryString.Get("Introduce");
            string Detail = Request.QueryString.Get("Detail");
            string page = Request.QueryString.Get("page");
            List<tbProduct> list = _bizProduct.Search(keyword, type, Introduce, Detail, page);
            if (list.Count == 0)
            {
                mainlist.Visible = false;
                mainlist = null;
            }
            else
            {
                mainlist.DataSource = list;
                mainlist.DataBind();
            }
            numberItem.Text = _bizProduct.NumberItems.ToString();
            if (Session["user"] != null)
            {
                HL_tab_login.NavigateUrl = "/gui/Account.aspx";
                HL_tab_login.Text = ((tbCustomer)Session["user"]).Username;
                HL_tab_Logout.Visible = true;
            }

            ListCartRight.DataSource = (List<bizCart>)Session["cart"];
            ListCartRight.DataBind();
            lb_Sum.Text = String.Format("{0:0,0 VNĐ}", bizCart.SumAllList((List<bizCart>)Session["cart"]));
            lb_Sum_product.Text = String.Format("{0:0,0 VNĐ}", bizCart.SumAllList((List<bizCart>)Session["cart"]));
        }
    }
}